package com.ssyc.student.adapter;

import android.content.Context;
import android.graphics.Color;
import android.graphics.Paint;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.style.ForegroundColorSpan;
import android.text.style.UnderlineSpan;
import android.widget.TextView;

import com.ssyc.common.adapter.CommonAdapter;
import com.ssyc.common.adapter.ViewHolder;
import com.ssyc.student.R;

import java.util.List;

/**
 * 学生端--写作第二题型答案列表展示的适配器
 * Created by Kevin on 2018/6/6
 */

public class StWriteAnswerLvAdapter extends CommonAdapter<String> {

    private Context context;

    public StWriteAnswerLvAdapter(Context context, List<String> datas, int layoutId) {
        super(context, datas, layoutId);
        this.context = context;
    }

    @Override
    public void convert(ViewHolder holder, String datas) {
        //答案
        TextView tv_answer = holder.getView(R.id.tv_answer);

        SpannableStringBuilder content = new SpannableStringBuilder(datas);
        ForegroundColorSpan colorSpan = new ForegroundColorSpan(Color.parseColor("#FF0000"));
        content.setSpan(colorSpan, 0,  1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
        content.setSpan(new UnderlineSpan(),
                0, 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        tv_answer.setText(content);
        tv_answer.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);




    }
}
